﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace OnlineGameLibrary.Contract
{
    [DataContract(Namespace = "http://gameservice")]
    public partial class GameRoom:INotifyPropertyChanged
    {
        public GameRoom()
        {
            Players = new ObservableCollection<Player>();
        }

        [DataMember]
        public GameInfo GameInfo { set; get; }

        Guid _guidid;
        [DataMember]
        public Guid GameId
        {
            get
            {
                return _guidid;
            }
            set
            {
                if (_guidid != value)
                {
                    _guidid = value;
                    onPropertyChanged("GameId");
                }
            }
        }

        GameConfig _gameconfig;
        [DataMember]
        public GameConfig GameConfig
        {
            get
            {
                return _gameconfig;
            }
            set
            {
                if (_gameconfig != value)
                {
                    _gameconfig = value;
                    onPropertyChanged("GameConfig");
                }
            }
        }

        ObservableCollection<Player> _players;
        [DataMember]
        public ObservableCollection<Player> Players
        {
            get
            {
                return _players;
            }
            set
            {
                if (_players != value)
                {
                    _players = value;
                    onPropertyChanged("Players");
                }
            }
        }

        GameState _gamestate;
        [DataMember]
        public GameState GameState
        {
            get
            {
                return _gamestate;
            }
            set
            {
                if (_gamestate != value)
                {
                    _gamestate = value;
                    onPropertyChanged("GameState");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        void onPropertyChanged(string propertyname)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this,
                    new PropertyChangedEventArgs(propertyname));
            }
        }
    }
}
